import { create } from 'zustand'
import { createJSONStorage, persist } from 'zustand/middleware'
import Oauth2TokenInfoDto from '@/core/oauth2/types/model/dto/Oauth2TokenInfoDto'
import globalConfig from '@/core/framework/config/globalConfig'

const useAppTokenInfoStore = create(
	persist<Oauth2TokenInfoDto>(
		(setState, getState) => {
			return {} as Oauth2TokenInfoDto
		},
		{
			name: `${globalConfig.storageKeyPrefix}.app.token`,
			storage: createJSONStorage(() => localStorage),
		},
	),
)

export default useAppTokenInfoStore
